<?php

namespace app\common\model;

use app\common\model\TimeModel;

class Order extends TimeModel
{

    protected $name = "order";

    protected $deleteTime = "delete_time";
    protected $defaultSoftDelete = 0;


    public function shop()
    {
        return $this->hasOne(Shop::class, 'id', 'shop_id');
    }

    public function goodsShop()
    {
        return $this->hasOne(Shop::class, 'id', 'goods_shop_id');
    }

    public function goods()
    {
        return $this->hasOne(Goods::class, 'id', 'goods_id');
    }

    public function sku()
    {
        return $this->hasOne(GoodsSku::class, 'id', 'sku_id');
    }

    public function user()
    {
        return $this->hasOne(User::class, 'id', 'user_id');
    }

    //获取订单状态
//    public function getTypeAttr($value, $data)
//    {
//        if ($data['status'] == 1) {
//            return 3;  //订单已完成
//        }
//        if ($data['express_time'] != 0 && $data['receive_time'] == 0) {
//            return 2;  //订单已发货  待收货
//        }
//        if ($data['express_time'] == 0) {
//            return 1; //订单待发货
//        }
//        if($data['refund_status'] == 2 ){
//            return 4; //订单已退款
//        }
//    }

}